<form class="layui-form detail_form" action="" lay-filter="sys_dic-edit-form">
    <input type="hidden" name="dic_id" value="#(detail.dic_id)">
 
  
  
  
 
  
  
  
    
    
    
    
            
                    <div class="layui-form-item">
                        <label class="layui-form-label">字典代码</label>
                        <div class="layui-input-block">
                            <input type="text" name="dic_code" value="#(detail.dic_code)" lay-verify="required" placeholder="请输入字典代码" class="layui-input" autocomplete="off">
                        </div>
                    </div>
            
    
    
  
 
  
  
  
    
    
    
    
            
                    <div class="layui-form-item">
                        <label class="layui-form-label">字典名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="dic_name" value="#(detail.dic_name)" lay-verify="required" placeholder="请输入字典名称" class="layui-input" autocomplete="off">
                        </div>
                    </div>
            
    
    
  
 
  
  
  
    
    
    
    
            
                    <div class="layui-form-item">
                        <label class="layui-form-label">字典值</label>
                        <div class="layui-input-block">
                            <input type="text" name="dic_value" value="#(detail.dic_value)" lay-verify="" placeholder="请输入字典值" class="layui-input" autocomplete="off">
                        </div>
                    </div>
            
    
    
  
 
  
  
  
    
    
    
    
            
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="create_datetime" lay-verify="" id="create_datetime_type_datetime"class="layui-input" placeholder="yyyy-MM-dd HH:mm:ss"  value="#date(detail.create_datetime,'yyyy-MM-dd HH:mm:ss')">
                        </div>
                    </div>
                
    
    
  
 
  
  
  
    
    
    
    
            
                    <div class="layui-form-item" >
                        <label class="layui-form-label">是否启用</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_enable" lay-verify="" value="true" title="是" #(detail.is_enable?'checked':'')>
                            <input type="radio" name="is_enable" lay-verify="" value="false" title="否" #(!detail.is_enable?'checked':'')>
                        </div>
                    </div>
                
    
    
  
 
  
  
  
    
    
    
    
            <!-- 下拉表单 -->
            <div class="layui-form-item">
                <label class="layui-form-label">上级编号</label>
                <div class="layui-input-block">
                    <select id="dic_pid_form_select"  name="dic_pid" lay-verify="" xm-select-search="" xm-select-radio=""
                            placeholder="请选择上级编号" autocomplete="off" xm-select-height="36px" xm-select-skin="normal" xm-select="dic_pid_form_select" lay-filter="dic_pid_form_select" >
                        <option value="">请选择上级编号</option>
                    </select>
                </div>
            </div>
        
    
  

    <div class="detail_form_footer">
        <a class="layui-btn" lay-submit lay-filter="btn-sys_dic-submit">保存</a>
        <a class="layui-btn layui-btn-primary" lay-filter="btn-sys_dic-cancle">取消</a>
    </div>
</form>

<script>
    layui.use(['admin', 'form', 'laydate','formSelects'], function () {
        var $ = layui.$
            , admin = layui.admin
            , element = layui.element
            , layer = layui.layer
            , laydate = layui.laydate
            , table = layui.table
            , formSelects = layui.formSelects
            , form = layui.form;

        form.render(null, 'sys_dic-edit-form');
 
  
    
    
            
    
  
 
  
    
    
            
    
  
 
  
    
    
            
    
  
 
  
    
    
            
    
  
 
  
    
    
            
                //渲染创建时间日期时间选择器
                laydate.render({ elem: '#create_datetime_type_datetime' ,type: 'datetime' });
            
    
  
 
  
    
    
            
    
  
 
  
    
    
            var initValue = '#(detail.dic_pid)';
            //渲染上级编号下拉分页选择器
            formSelects.data('dic_pid_form_select', 'server', {
                url: '/system/dic/list',
                keyName: 'dic_name',
                keyVal: 'dic_id',
                searchName: 'dic_name__op__like',
                showPage: true,
                size: 10,
                // 初始值设置
                initValues: initValue&&initValue!='0'?[initValue]:[],
            });
        
  


        /* 自定义验证规则 */
        form.verify({
            title: function (value) {
                if (value.length < 5) {
                    return '标题至少得5个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        /* 监听提交 */
        form.on('submit(btn-sys_dic-submit)', function (data) {
            layer.msg('正在保存中，请稍候', {icon: 16});
            $.ajax({
                method: 'post',
                url: "/system/dic/save",
                data: data.field,
                dataType: 'json',
                success: function (rs) {
                    if (rs.success) {
                        layer.msg(rs.message || '保存成功', {icon: 6});
                        let config = #(detail.dic_id == null ? '{page: {curr: 1}}' : '{}');
                        table.reload('sys_dic-table', config);
                        layer.closeAll('page'); //关闭所有页面层
                    } else {
                        layer.msg('保存失败,' + rs.message || '保存失败', {icon: 5});
                    }
                },
                error: function (a, b, c) {
                    layer.msg('请求异常，保存失败', {icon: 5});
                }
            });
            return false;
        });
        /* 监听取消 */
        $("[lay-filter=btn-sys_dic-cancle]").click(function () {
            layer.closeAll("page");
        });
    });
</script>